package org.douxiaoban.client.adapter;

import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import org.douxiaoban.client.api.TopSubjectRecord;

 import java.awt.*;
import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: huangzhongkun
 * Date: 11-6-15
 * Time: 下午4:54
 */
public class TopAdapter extends BaseAdapter{

    public ArrayList<TopSubjectRecord> topSubjectRecordArrayList =
            new ArrayList<TopSubjectRecord>();
    private ImageView _default_pic;

    public TopAdapter(ImageView pic){
        _default_pic = pic;
    }

    @Override
    public int getCount() {
        return topSubjectRecordArrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        if(topSubjectRecordArrayList.get(i).image_bitmap!=null)
           return topSubjectRecordArrayList.get(i).image_bitmap;
        else
            return topSubjectRecordArrayList.get(i).default_image;

    }
}
